# php develop env - A base ubuntu 20
# ubuntu common dockerfile
FROM ubuntu:20.04

LABEL maintainer="Markway<ljwnet163@163.com>" version="server.php74.001" license="MIT"
# 引入系统变量
ARG timezone

ENV APP_ENV=prod \
    # 时区
    TIMEZONE=${timezone:-"Asia/Shanghai"} \
    DEBIAN_FRONTEND=noninteractive
WORKDIR /tmp/deb
RUN set -ex && \
    apt update && \
    # https前置
    apt install -y apt-utils ca-certificates && \
    # 换阿里的源镜像(可选)
    cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
    sed -i 's/http\:\/\/archive\.ubuntu\.com/https:\/\/mirrors\.aliyun\.com/g' /etc/apt/sources.list && \
    # 更新源列表 (必须de)
    apt update && \
    # 更新应用 (可选)
    #apt upgrade -y && \
    # apt管理工具 add-apt-repository[apt-utils]
    apt install -y apt-transport-https tzdata && \
    ln -fs /usr/share/zoneinfo/PRC /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata && \
    # app编译安装相关
    apt install -y libtool gcc software-properties-common && \
    # php repo add ubuntu默认php版本 就是7.4
    # add-apt-repository ppa:ondrej/php && \
    # add-apt-repository ppa:chris-lea/redis-server && \
    apt update && \
    # php
    apt install -y php7.4 php7.4-fpm php7.4-dev php7.4-curl php7.4-gd php7.4-mysql  php7.4-redis php7.4-mbstring php7.4-xml php7.4-bcmath php7.4-opcache php7.4-zip && \
    # apt install -y php-pear && 
    # composer  的待完善
    # pecl install swoole
    # socket改成端口
    LISTEN_LINE_INFO=`more /etc/php/7.4/fpm/pool.d/www.conf | grep 'listen =' -n` && \
    sed -i ${LISTEN_LINE_INFO%%\:*}'i listen = 9074' /etc/php/7.4/fpm/pool.d/www.conf && \
    sed -i 's/^listen = \(.*\).sock/;listen=(\1).sock/g' /etc/php/7.4/fpm/pool.d/www.conf && \
    service php7.4-fpm restart && \
    service php7.4-fpm status

EXPOSE 9074
#ENTRYPOINT ["service","enable","php7.4-fpm"]


